const axios = require('axios')
const ora = require('ora')

let testURL = 'http://124.127.117.217:58000'
let productionURL = 'http://10.143.19.57:29001'

let urlList = [
  '/northbound/getAllPhysicalTerminationPoints',
  '/northbound/getAllFloatingTerminationPoints',
  '/northbound/getConnectionTerminationPoints',
  '/northbound/getEquipments'
]

let data = {
  ip: "10.1.20.2",
  devId: "98:00:74:6d:d4:bc"
}

urlList.forEach(async url => {
  let loading = ora().start()
  try {
    let res = await axios.post(testURL + url, {
      data,
      headers: {
        'content-type': 'application/json'
      }
    })
    let key = Object.keys(res.data.data)[0]
    let ans = res.data.data[key].filter(val => 'name' in val)
    loading.succeed(`${url} : ${ans.length}`)
  } catch {
    loading.fail(url)
  }
})
